package com.example.feitiansys.controller;


import com.example.feitiansys.pojo.SalarySheet;
import com.example.feitiansys.service.salarySheet.SalarySheetService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 工资条
 */
@Controller
public class SalarySheetController {
    @Resource
    SalarySheetService salarySheetService;

    @RequestMapping("/system/salarysheet")
    public String salarysheetshow(){
        return "/system/salarysheet/salarysheet";
    }
    @RequestMapping("/system/salarysheet/update")
    public String update(){
        return "/system/salarysheet/update";
    }

    @RequestMapping("/system/salarysheet/add")
    public String salarysheetaddshow(){
        return "system/salarysheet/add";
    }

    @RequestMapping("/system/salarysheet/getsalarysheets")
    @ResponseBody
    public Object getsalarysheets(SalarySheet salarySheet){
        if (salarySheet==null){
            salarySheet=new SalarySheet();
        }
        return salarySheetService.queryAll(salarySheet);
    }

    @RequestMapping("/system/salarysheet/removes")
    @ResponseBody
    public Object removesalarysheets(String array){
        String[] split = array.split(",");
        return salarySheetService.deleteByIds(split);
    }

    @RequestMapping("/system/salarysheet/remove")
    @ResponseBody
    public Object removesalarysheet(Integer id){
        return salarySheetService.deleteById(id);
    }

    @RequestMapping("/system/salarysheet/doadd")
    @ResponseBody
    public int salarysheetdoadd(SalarySheet salarySheet){
        int insert = salarySheetService.insert(salarySheet);
        return insert;
    }
    @RequestMapping("/system/salarysheet/getsalarysheetbyid")
    @ResponseBody
    public Object getsalarysheetbyid(Integer id){
        return salarySheetService.queryById(id);
    }
    @RequestMapping("/system/salarysheet/doupdate")
    @ResponseBody
    public Object update(SalarySheet salarySheet){
        return salarySheetService.update(salarySheet);
    }
}
